home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Reference / the cmsp digests ('94-'97) / csmp digest Vol 3 No 089 < prev    next >
Text File  |  1995-03-21  |  69KB  |  1,850 lines

  1. C.S.M.P. Digest             Sat, 18 Mar 95       Volume 3 : Issue 89
  2.  
  3. Today's Topics:
  4.  
  5.         Asynchronous file read-write example
  6.         Getting the real time frame rate of QT movies
  7.         Help!  Scroll bars are crashing!!!
  8.         Help! JPEG-QT decompression
  9.         How can I open a System7 sound file?
  10.         Is it safe to call LaunchApplication from an extension?
  11.         My own Color Table??
  12.         Need help with calling CODE resources
  13.         Q: TextEdit view-dest rectangles - documented where?
  14.         Q: What are Exceptions?
  15.         Screen saver info needed
  16.         Transparent QuickTime?
  17.  
  18.  
  19.  
  20. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  21. (pottier@clipper.ens.fr).
  22.  
  23. The digest is a collection of article threads from the internet newsgroup
  24. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  25. regularly and want an archive of the discussions.  If you don't know what a
  26. newsgroup is, you probably don't have access to it.  Ask your systems
  27. administrator(s) for details.  If you don't have access to news, you may
  28. still be able to post messages to the group by using a mail server like
  29. anon.penet.fi (mail help@anon.penet.fi for more information).
  30.  
  31. Each issue of the digest contains one or more sets of articles (called
  32. threads), with each set corresponding to a 'discussion' of a particular
  33. subject.  The articles are not edited; all articles included in this digest
  34. are in their original posted form (as received by our news server at
  35. nef.ens.fr).  Article threads are not added to the digest until the last
  36. article added to the thread is at least two weeks old (this is to ensure that
  37. the thread is dead before adding it to the digest).  Article threads that
  38. consist of only one message are generally not included in the digest.
  39.  
  40. The digest is officially distributed by two means, by email and ftp.
  41.  
  42. If you want to receive the digest by mail, send email to listserv@ens.fr
  43. with no subject and one of the following commands as body:
  44.     help                                Sends you a summary of commands
  45.     subscribe csmp-digest Your Name     Adds you to the mailing list
  46.     signoff csmp-digest                 Removes you from the list
  47. Once you have subscribed, you will automatically receive each new
  48. issue as it is created.
  49.  
  50. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  51. Questions related to the ftp site should be directed to
  52. scott.silver@dartmouth.edu.
  53.  
  54. -------------------------------------------------------
  55.  
  56. >From niemann@mo.net (Jim Niemann)
  57. Subject: Asynchronous file read-write example
  58. Date: 1 Mar 1995 23:41:05 GMT
  59. Organization: -=MO.NET=- P-Net, Inc's Missouri Operations
  60.  
  61. Does anyone have any Macintosh C examples of performing file reading
  62. and writing asynchronously?
  63.  
  64. Thanks
  65. Jim Niemann 
  66.  
  67. The opinions contained herein do not represent those held by
  68. any person living or dead.
  69.  
  70. +++++++++++++++++++++++++++
  71.  
  72. >From bb@lightside.com (Bob Bradley)
  73. Date: 2 Mar 1995 03:45:42 GMT
  74. Organization: SPC
  75.  
  76. In article <3j30mh$e33@Twain.MO.NET>, niemann@mo.net (Jim Niemann) wrote:
  77.  
  78. > Does anyone have any Macintosh C examples of performing file reading
  79. > and writing asynchronously?
  80.  
  81. There's a good article in Develop about using Async routines. It has a lot
  82. of good examples. I think the examples are all based around the PPC
  83. ToolBox but, adapting it to use the File Manager is simple, the concepts
  84. are the same. It's in the March 93 issue of Develop (not sure the exact
  85. number).
  86.  
  87. +++++++++++++++++++++++++++
  88.  
  89. >From oster@netcom.com (David Phillip Oster)
  90. Date: Thu, 2 Mar 1995 18:27:41 GMT
  91. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  92.  
  93. In article <3j30mh$e33@Twain.MO.NET> niemann@mo.net (Jim Niemann) writes:
  94. >Does anyone have any Macintosh C examples of performing file reading
  95. >and writing asynchronously?
  96.  
  97. Note that although you can call PBReadAsync and PBWriteAsync, if the
  98. file is located on a hard disk, you won't actually get any asynchronous
  99. behavior. PBReadAsync will do the read, call your completion routine, and
  100. then PBReadAsync will return.
  101.  
  102. PBReadAsync returns immediately if the destination is a floppy, and the
  103. read is truly asynchronous: when the read completes, your completion
  104. routine will be called at interrupt time.
  105.  
  106. SCSI Manager 4.3 may have changed the picture, but that is the way things
  107. have stood ever since SCSI Manager came out in '85.
  108.  
  109. This failure of PBReadAsync and PBWriteAsync to be truly asynchronous 
  110. means that if you do further i/o from your completion routines, you'll
  111. be using more and more stack.  Note that this is only a problem for
  112. refNums that aren't really asynchronous.
  113.  
  114. Here is some code for you:
  115.  
  116. It is the asynchronous analog of FSRead, FARead, which takes:
  117. a buffer to read into, the length to read, a routine to be called when
  118. the routine completes, and a pointer to a big data structure that contains
  119. all the parameter blocks that the interrupt-time state machine needs to
  120. do its job. Some fields of the line->read.pb parameter block have been
  121. pre-initialized with values like CurrentA5, and the address of the interface
  122. completion routine, which sets up the environment and then calls the user's
  123. completion routine.
  124.  
  125. typedef struct LineRec *LinePtr;        /* forward declare LinePtr */
  126. typedef void (*LineFunc)(LinePtr);
  127. typedef void (*LineCompleteFunc)(ParmBlkPtr, LinePtr);
  128.  
  129. /* to get at our environment, we need to declare a record with a 
  130.         ParamBlockRec as first element, and pointers after that give us what we need.
  131.  */
  132. typedef struct FARec {
  133.         ParamBlockRec           pb;
  134.         LinePtr                         line;                   /* reference to owning line */
  135.         LineCompleteFunc        complete;               /* completion routine for this io. */
  136. }FARec, *FAPtr;
  137.  
  138. /* FAReadFile - asynchronous analog of FSRead
  139.  */
  140. OSErr   FAReadFile(Ptr buffer, long len, LineCompleteFunc lfunc, LinePtr line){
  141.         FAPtr   fap;
  142.  
  143.         fap = &line->readFile;
  144.         fap->pb.ioParam.ioBuffer = buffer;
  145.         fap->pb.ioParam.ioReqCount = len;
  146.         fap->complete = lfunc;
  147.         return PBReadAsync(&fap->pb);
  148. }
  149. -- 
  150. - ------- <mail-to:oster@netcom.com> ----------
  151. There is no sight finer than that of the planet Earth in your rearview mirror.
  152.  
  153.  
  154.  
  155. ---------------------------
  156.  
  157. >From enrico.ballarin-dolfin@svusenet.ubs.ch
  158. Subject: Getting the real time frame rate of QT movies
  159. Date: Tue, 21 Feb 1995 08:49:13 +0100
  160. Organization: Union Bank of Switzerland
  161.  
  162. Hi!
  163.  
  164. I would like to get the effective current frame rate of a playing QT
  165. movie in real time.
  166. The application JimTV had such a feature but is no more working with QT 2.0.
  167. JimTV displays both the fps at which the movie was recorded AND the
  168. current fps in real time.
  169.  
  170. Thanks in advance for hints!
  171.  
  172. Enrico
  173.  
  174. -- 
  175. Enrico Ballarin Dolfin                      Union Bank of Switzerland
  176.  
  177. email: enrico.ballarin-dolfin@zh002.ubs.ubs.ch
  178.        enrico_ballarin_dolfin@macquality.ch
  179.        enrico@ezinfo.vmsmail.ethz.ch
  180.  
  181. -- 
  182. Enrico Ballarin Dolfin                      Union Bank of Switzerland
  183.  
  184. email: enrico.ballarin-dolfin@zh002.ubs.ubs.ch
  185.        enrico_ballarin_dolfin@macquality.ch
  186.        enrico@ezinfo.vmsmail.ethz.ch
  187.  
  188. +++++++++++++++++++++++++++
  189.  
  190. >From sandvik@apple.com (Kent Sandvik)
  191. Date: Sat, 04 Mar 1995 15:28:29 -0800
  192. Organization: Apple Computer, Inc. Developer Technical Support
  193.  
  194. In article <enrico.ballarin-dolfin-2102950849130001@137.156.227.57>,
  195. enrico.ballarin-dolfin@svusenet.ubs.ch wrote:
  196.  
  197. > Hi!
  198. > I would like to get the effective current frame rate of a playing QT
  199. > movie in real time.
  200. > The application JimTV had such a feature but is no more working with QT 2.0.
  201. > JimTV displays both the fps at which the movie was recorded AND the
  202. > current fps in real time.
  203.  
  204. MoviePlayer 2.0b2 has this feature. If I would do this, there would be at
  205. least two options:
  206.  
  207. a) lazy interpolation
  208. count the amount of frames (video samples) in the movie using
  209. GetNextInterestingTime, and get the duration of the movie, and divide.
  210.  
  211. b) more exact calculation while the movie plays
  212. You install a moviedrawingcomplete proc that is triggered every time a
  213. frame is drawn, have a counter, and calculate on the flight or later how
  214. many frames you are drawing per known time unit.
  215.  
  216. Note that there are no hints when QT will drop frames, but
  217. moviedrawingComplete proc is guaranteed to trigger for drawn frames. See
  218. Tech Note QT1 (or old pre-Kent time of DTS QT-3 1.6.1 QT Features) for
  219. info about movieDrawingComplete procs.
  220.  
  221. Just to end this more philosophically, QT has not stored notation of frame
  222. rate with the exception of how many video samples you have in the movie,
  223. and how long these are. The rate definition is like the gas pedal of the
  224. car, it controls how fast the movie plays (and direction), the scale
  225. defines how many units you could have within one 1 second period. The
  226. underlying clock is the main clock in the universe, ticking along and
  227. providing time for the playing movie.
  228.  
  229. --Kent
  230.  
  231. -- 
  232. Kent Sandvik   sandvik@apple.com                  Working with Multimedia stuff...
  233. Apple Developer Technical Support.                                     Private activities on Internet.
  234.  
  235. ---------------------------
  236.  
  237. >From timmyd@netcom.com (Tim DeBenedictis)
  238. Subject: Help!  Scroll bars are crashing!!!
  239. Date: Mon, 27 Feb 1995 19:37:36 GMT
  240. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  241.  
  242. I am writing some scroll bar code.  It is all working fine, except when
  243. I try to use a callback routine for tracking the thumb of the scroll
  244. bar.
  245.  
  246. Here is the relevant part of the code:
  247.  
  248.         part = FindControl ( where, window, &control );
  249.  
  250.         if ( control && part )
  251.         {
  252.                 upp = NewControlActionProc ( sDoControlAction );
  253.                 part = TrackControl ( control, where, upp );
  254.                 DisposeRoutineDescriptor ( upp );
  255.         }
  256.  
  257. The sDoControlAction() function is defined as follows:
  258.  
  259. pascal void sDoControlAction ( ControlHandle control, short part )
  260. {
  261.         WindowPtr       window;
  262.  
  263.         window = (*control)->contrlOwner;
  264.  
  265.         switch ( part )
  266.         {
  267.                 case inButton:
  268.                 case inCheckBox:
  269.                 case inUpButton:
  270.                 case inDownButton:
  271.                 case inPageUp:
  272.                 case inPageDown:
  273.                 case inThumb:
  274.                         break;
  275.         }
  276. }
  277.  
  278. Again, it all works fine, EXCEPT when the mouse is clicked in the thumb
  279. part of the scroll bar.  Any other part of the scroll bar works fine.
  280. When the mouse is clicked in the thumb, the program crashes immediately.
  281. Stepping through with the debugger, I see that TrackControl() is not
  282. passing my sDoControlAction() procedure the correct handle to the
  283. scroll bar when the part code correspnds to the scroll bar thumb.  It works
  284. fine for every other part code.  It DOES NOT crash if I use the default
  285. control-tracking procedue (i.e., by passing NULL instead of sDoControlAction
  286. to TrackControl) instead.
  287.  
  288. It also works fine if the control is anything other than a scroll bar,
  289. with both the default tracking procedure and my own sDoControlAction
  290. procedure.
  291.  
  292. I get the same behavior whether I load the scroll bar from a 'CNTL'
  293. resource template, allocate it directly using NewControl(), run with
  294. extensions on or off, use 32-bit addressing or not.
  295.  
  296. Has anybody ever seen anything like this?  This is really basic code...
  297. I've done many a scroll bar before and I've never seen anything like this.
  298. I'm running System 7.5 on a Quadra 610 using CodeWarrior CW5.  I get the
  299. same result when I compile with THINK C 5.0.4, so I'm pretty sure it's
  300. something I'm doing wrong, rather than a compiler bug.
  301.  
  302. Thanks in advance,
  303.  
  304. -Tim DeBenedictis
  305.  
  306.  
  307. +++++++++++++++++++++++++++
  308.  
  309. >From Matt Slot <fprefect@umich.edu>
  310. Date: 28 Feb 1995 01:41:52 GMT
  311. Organization: University of Michigan
  312.  
  313. In article <timmydD4oBup.K7K@netcom.com> Tim DeBenedictis,
  314. timmyd@netcom.com writes:
  315. >Has anybody ever seen anything like this?  This is really basic code...
  316. >I've done many a scroll bar before and I've never seen anything like
  317. this.
  318.  
  319. This is one of the inconsistencies of the Toolbox... there are 2 types of
  320. routines that handle control actions. The first handles clicks in the 
  321. page up/down, scroll up/down parts of a control -- just what you already
  322. have. The second handles tracking dial indicators -- like the thumb area
  323. of the scroller, and has a totally different calling convention.
  324.  
  325.         pascal void myScrollAction( ControlHandle theControl, short ctrlPart);
  326.  
  327.         pascal void myDialAction(void);
  328.         
  329. You have to test which portion of the control was clicked in, then set the
  330. track-handler based on that.
  331.  
  332. Its a stumper that took me a week to fix... hope this helps you. :)
  333.  
  334. Matt
  335.  
  336. +++++++++++++++++++++++++++
  337.  
  338. >From bb@lightside.com (Bob Bradley)
  339. Date: 1 Mar 1995 09:05:25 GMT
  340. Organization: SPC
  341.  
  342. In article <timmydD4oBup.K7K@netcom.com>, timmyd@netcom.com (Tim
  343. DeBenedictis) wrote:
  344.  
  345. > I am writing some scroll bar code.  It is all working fine, except when
  346. > I try to use a callback routine for tracking the thumb of the scroll
  347. > bar.
  348.  
  349. [Code Deleted]
  350.   
  351. > Again, it all works fine, EXCEPT when the mouse is clicked in the thumb
  352. > part of the scroll bar.  Any other part of the scroll bar works fine.
  353. > When the mouse is clicked in the thumb, the program crashes immediately.
  354. > Stepping through with the debugger, I see that TrackControl() is not
  355. > passing my sDoControlAction() procedure the correct handle to the
  356. > scroll bar when the part code correspnds to the scroll bar thumb.  It works
  357. > fine for every other part code.  It DOES NOT crash if I use the default
  358. > control-tracking procedue (i.e., by passing NULL instead of sDoControlAction
  359. > to TrackControl) instead.
  360.  
  361. For some reason, TrackControl doesn't use the same action proc when
  362. dealing with inThumb hits. There's been quite a few messages about this
  363. lately, if it's not in the FAQ, it probably should be.
  364.  
  365. +++++++++++++++++++++++++++
  366.  
  367. >From jaks@netcom.com (Eric Jackson)
  368. Date: Wed, 1 Mar 1995 18:08:23 GMT
  369. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  370.  
  371. In article <bb-2903950105100001@user33.lightside.com>,
  372. Bob Bradley <bb@lightside.com> wrote:
  373. >In article <timmydD4oBup.K7K@netcom.com>, timmyd@netcom.com (Tim
  374. >DeBenedictis) wrote:
  375. >
  376. >> I am writing some scroll bar code.  It is all working fine, except when
  377. >> I try to use a callback routine for tracking the thumb of the scroll
  378. >> bar.
  379. >
  380. >
  381. >For some reason, TrackControl doesn't use the same action proc when
  382. >dealing with inThumb hits. There's been quite a few messages about this
  383. >lately, if it's not in the FAQ, it probably should be.
  384.  
  385. The reason is that the scroll bar thumb is an indicator.
  386.  
  387. On page 336 of inside machintosh volume one you will find
  388.  
  389. Action Procedure for TrackControl
  390.  
  391. If an indicator Procedure MyAction
  392. If not an indicator Procedure MyAction(theControl:ControlHandle;PartCode:integer);
  393.  
  394. I had this exact same trouble.  Think is that according to the user interface
  395. guidelines while the user is moving the thumb around you dont really need to do 
  396. anything.  But when the user lets up on the mouse you need to find out how
  397. far the mouse has moved and scroll accordingly after the call to TrackControl
  398. is over.
  399.  
  400. What I have found works is that you need to have two calls to track
  401. control.  One for if the user clicked in the thumb and one for if the
  402. user did not click in the thumb.  It the user clicked in the thumb
  403. then pass nil to TrackControl but if the user clicked in one of the
  404. other parts of the scroll bar pass your action procedure.
  405.  
  406. Here is an example
  407.  
  408.  function ScrollBar.GetActionProc: ProcPtr;
  409.  
  410. {This method is called from ControlObject.HandleMouseDownEvent.  }
  411. {What it does is to provide the action procedure that we will pass}
  412. {to the ToolBox routine TrackControl.  We need to override this}
  413. {method for the ScrollBar because it needs to pass nil when the}
  414. {user clicks in the thumb and its normal at all other times}
  415.  
  416. {The ScrollBar does not have its}
  417. {own HandleMouseDownEvent method but instead }
  418. {inherites it from the ControlObject.  }
  419. {When the user clicks the mouse down in a ScrollBar,}
  420. {ControlObject.HandleMouseDownEvent is called from}
  421. { MouseDownEvent.HandleEvent which is called as an}
  422. {inherited method from ScrollEvent.HandleEvent from the main program.}
  423.  
  424. {Normally we use the inherited method for geting }
  425. {the action procedure but when the user has clicked in}
  426. {the Thumb we need to return nil here since we are working with an indicator.}
  427.  
  428. {The inherited method by the way returns }
  429. {StandardControlActionProc which works by calling}
  430. {ScrollBar.CallFromInsideTrackControl.}
  431.  
  432.  begin
  433.   if Action <> inthumb then
  434.    GetActionProc := inherited GetActionProc
  435.   else
  436.    GetActionProc := nil;
  437. {If the user clicks in the thumb we need to return nil here since the thumb is}
  438. {an indicator}
  439.  end;
  440. Here is the method which called it.
  441.  
  442.  procedure ControlObject.HandleMouseDownEvent;
  443.  
  444. {When the user clicks the mouse down in a ControlObject }
  445. {in a regular window then this method is called.}
  446. {If except if the ControlObject}
  447. {is  in an Active DialogWindow  we}
  448. {would call DialogWindow.HandleAnyEvent}
  449.  
  450. {Much of the work of this method is done by calling the }
  451. {ToolBox routine TrackControl.  For example}
  452. {when the user clicks the mouse down in a ScrollBar }
  453. {in a region other than the Thumb then}
  454. {this TrackControl is called so that we can use the }
  455. {StandardControlObjectActionProc  to do the rest of the work}
  456. {for the control.  StandardControlObjectActionProc }
  457. {uses the ControlHandle to find the ControlObject and}
  458. {then calls the ControlObject.CallFromInsideTrackControl .}
  459. {For example the ScrollBar.CallFromInsideTrackControl method}
  460. {will do the rest of the work of scrolling.     }
  461.  
  462. {If however the user has clicked on the thumb, since it}
  463. {is an indicator the}
  464. {ScrollBar.GetActionProcedure returns nil and nothing }
  465. {is done until the user lets up on the mouse and}
  466. {then the ScrollBar.DoAfterTracking takes care of the }
  467. {work of moving to the new correct scroll possition.}
  468.  
  469. {In the MacWireFrame application the WireFrameWindows }
  470. {have six buttons named Tx,Ty,Tz,Rx,Ry and}
  471. {Rz.  These are AppleEventDrivenControls work by }
  472. {sending an AppleEvent to the MasterMessageReciever,}
  473. {which then takes control till the user lets the mouse up.}
  474.  
  475. {When the user clicks on one of the Dxy, Dyz or Dzx radio buttons in the }
  476. {upper left hand side of the MacWireFrame window nothing happens }
  477. {inside track control but when the user lets up on the mouse}
  478. { the SetDragModeRadioButton.DoAfterTracking;}
  479. {which overrides the standard ControlObject}
  480. { method is called to handle the work.  }
  481. {SetDragModeRadioButton calls the}
  482. {inherited method RadioButton.DoAfterTracking }
  483. {in order to do the work of Switching the Button.  }
  484.  
  485. {This method is also called when the user clicks }
  486. {the mouse down in the ToolPaletteDialog in the}
  487. {MacSolidModel application in one of the two }
  488. {special RadioButtons named Solid and WireFrame when}
  489. {the ToolPaletteDialog is NOT the active or }
  490. {front most window.  When this happens isDialogEvent returns}
  491. {false durring classification so we wind up }
  492. {with a StandardControlEvent which calls }
  493. {MouseDownEvent.HandleEvent as an inherited }
  494. {method which calls this method.}
  495. {So this is how we implement a sort of floating window}
  496.   var
  497.    Mercury: point;
  498.    PartCode: integer;
  499.  begin
  500.   getMouse(Mercury);
  501.   Window(self.AssociatedWith).ClipRectSetToWholeWindow;
  502.   Self.StartTracking := True;
  503.   StartingValue := Self.GetControlValue;
  504.  
  505.   PartCode := TrackControl(Self.theControlHandle, mercury, SElf.GetActionProc);
  506.  
  507.   Self.DoAfterTracking(PartCode);
  508.  
  509.   Window(self.AssociatedWith).ClipRectSetToClipControls;
  510.  end;
  511. Hope this is of some help.  I got that tip about TrackControl
  512. from the net so now I felt that I needed to pass it on.
  513.  
  514. Eric Jackson
  515. jaks@netcom.com
  516.  
  517.  
  518. ---------------------------
  519.  
  520. >From hy@ix.netcom.com (Michael Hooton)
  521. Subject: Help! JPEG-QT decompression
  522. Date: 28 Feb 1995 08:07:45 GMT
  523. Organization: Netcom
  524.  
  525. My application requires decompression of JPEG files.  The files were 
  526. originally compressed on an IBM, then transferred in block format over 
  527. TCP/IP to a Tandem mainframe.  My application downloads it to the Mac.  
  528. Currently I write it in block format to a file.  Using a shareware JPEG 
  529. viewer I can see the picture but the viewer reports the data is 
  530. corrupted and the picture appears distorted.
  531.  
  532. I have three questions;
  533. 1) I attempt to decompress it using QT's DeCompress() which requires an 
  534. ImageDesrciptionRec.  Is the data for this embedded in the JPEG file, 
  535. and if so where?
  536.  
  537. 2) Could the data corruption be the result of a failure to swapint on 
  538. the part of the application that creates and uploads the file?  Are 
  539. there integer or long fields in the JPEG header?
  540.  
  541. 3)  Is my approach completely erroneous or just what is the best way to 
  542. display a JPEG file?
  543.  
  544. +++++++++++++++++++++++++++
  545.  
  546. >From ivanski@world.std.com (Ivan M CaveroBelaunde)
  547. Date: Thu, 2 Mar 1995 04:45:17 GMT
  548. Organization: The World Public Access UNIX, Brookline, MA
  549.  
  550. hy@ix.netcom.com (Michael Hooton) writes:
  551.  
  552. >I have three questions;
  553. >1) I attempt to decompress it using QT's DeCompress() which requires an 
  554. >ImageDesrciptionRec.  Is the data for this embedded in the JPEG file, 
  555. >and if so where?
  556.  
  557. Somewhere in the sample code for QT there's some code that tells
  558. you how to extract the information from the JFIF header in order
  559. to build an image description rec. Basically for the
  560. JPEG description rec all you really need is the image size (all
  561. the other fields you can figure otherwise). You can also look
  562. at the jpegview code.
  563.  
  564. -Ivan
  565. - -
  566. Ivan Cavero Belaunde (ivanski@world.std.com, ivan_cavero-belaunde@avid.com)
  567. Avid Technology, Inc.
  568.  
  569.  
  570. +++++++++++++++++++++++++++
  571.  
  572. >From sandvik@apple.com (Kent Sandvik)
  573. Date: Sat, 04 Mar 1995 15:34:14 -0800
  574. Organization: Apple Computer, Inc. Developer Technical Support
  575.  
  576. In article <D4sqJI.4rM@world.std.com>, ivanski@world.std.com (Ivan M
  577. CaveroBelaunde) wrote:
  578.  
  579. > hy@ix.netcom.com (Michael Hooton) writes:
  580. > >I have three questions;
  581. > >1) I attempt to decompress it using QT's DeCompress() which requires an 
  582. > >ImageDesrciptionRec.  Is the data for this embedded in the JPEG file, 
  583. > >and if so where?
  584. > Somewhere in the sample code for QT there's some code that tells
  585. > you how to extract the information from the JFIF header in order
  586. > to build an image description rec. Basically for the
  587. > JPEG description rec all you really need is the image size (all
  588. > the other fields you can figure otherwise). You can also look
  589. > at the jpegview code.
  590.  
  591. Yes, the sample is called JPEG File Interchange format, and if you search
  592. in the DTS sample code archives on ftp.info.apple.com, eWorld, AppleLink,
  593. developer CDs and any other place that has them, get the archive called
  594. Movie Data Exchange.
  595.  
  596. The image description record is not automatically embedded in the JPEG
  597. file, unless you had stored it originally under Mac inside a resource, or
  598. somewhere else in the file. But JFIF should give you the necessary
  599. meta-information in order to build an image description record.
  600.  
  601. --Kent
  602.  
  603. -- 
  604. Kent Sandvik   sandvik@apple.com                  Working with Multimedia stuff...
  605. Apple Developer Technical Support.                                     Private activities on Internet.
  606.  
  607. +++++++++++++++++++++++++++
  608.  
  609. >From Martin Frick <mfricke@indirect.com>
  610. Date: Tue, 7 Mar 1995 05:10:12 GMT
  611. Organization: Internet Direct, indirect.com
  612.  
  613. Subject: Re: Help! JPEG/QT decompression
  614. From: Kent Sandvik, sandvik@apple.com
  615. Date: Sat, 04 Mar 1995 15:34:14 -0800
  616. In article <sandvik-0403951534140001@17.255.38.138> Kent Sandvik,
  617. sandvik@apple.com writes:
  618. >In article <D4sqJI.4rM@world.std.com>, ivanski@world.std.com (Ivan M
  619. >CaveroBelaunde) wrote:
  620. >
  621. >> hy@ix.netcom.com (Michael Hooton) writes:
  622. >> 
  623. >> >I have three questions;
  624. >> >1) I attempt to decompress it using QT's DeCompress() which requires
  625. an 
  626. >> >ImageDesrciptionRec.  Is the data for this embedded in the JPEG file, 
  627. >> >and if so where?
  628. >> 
  629. >> Somewhere in the sample code for QT there's some code that tells
  630. >> you how to extract the information from the JFIF header in order
  631. >> to build an image description rec. Basically for the
  632. >> JPEG description rec all you really need is the image size (all
  633. >> the other fields you can figure otherwise). You can also look
  634. >> at the jpegview code.
  635. >
  636. >Yes, the sample is called JPEG File Interchange format, and if you search
  637. >in the DTS sample code archives on ftp.info.apple.com, eWorld, AppleLink,
  638. >developer CDs and any other place that has them, get the archive called
  639. >Movie Data Exchange.
  640. >
  641. >The image description record is not automatically embedded in the JPEG
  642. >file, unless you had stored it originally under Mac inside a resource, or
  643. >somewhere else in the file. But JFIF should give you the necessary
  644. >meta-information in order to build an image description record.
  645. >
  646. >--Kent
  647. >
  648. >-- 
  649. >Kent Sandvik   sandvik@apple.com                  Working with
  650. Multimedia stuff...
  651. >Apple Developer Technical Support.                                    
  652. Private 
  653. >activities on Internet.
  654.  
  655.  
  656. You may be interested in the fact that there is a bug in my somewhat old
  657. download of this code.  (This may have been put right, I have had no
  658. reason
  659. to look at more recent versions.)
  660.  
  661. They (Apple DTS) have a function 
  662.  
  663. char *
  664. MarkerDetect(char *byteStream,short *width,short *height,long *hRes,long
  665. *vRes,short *depth)
  666.  
  667. which runs to a couple of hundred lines or so with many local variables,
  668. and
  669. about half way through some checks occur like
  670.  
  671. switch (  tn=(dac_t2 & 0xf0) )  {
  672.                         case 0:
  673.                         case 0x10:
  674.                                 break;
  675.                         case 0xf0:
  676.                                 break;
  677.                         default:
  678.                                 status = 34;
  679.                                 break;
  680.  
  681.  
  682. where the default is an error. Now, in many JFIF files the local variable
  683. dac_t2
  684. is never assigned by the running code. It also turns out that it, and all
  685. the
  686. other local variables, are not initialized. If the function is compiled
  687. with
  688. a  Symantec compiler it runs fine, if you compile it with CW it can give
  689. an error even with a good JFIF file.
  690.  
  691. Remedy: initialize those variables. Thus (at least)
  692.  
  693. short   c1=0,hv1=0,q1=0,c2=0,hv2=0,q2=0,c3=0,hv3=0,q3=0;
  694. short   dac_t1=0, dac_t2=0, dac_t3=0;
  695.  
  696. Hope this may be a help to someone-- it certainly puzzled me for a while.
  697.  
  698. Sincerely,
  699.  
  700. M.
  701.  
  702. ---------------------------
  703.  
  704. >From smithab@forbin.syr.edu (core dumped)
  705. Subject: How can I open a System7 sound file?
  706. Date: 4 Mar 1995 18:56:24 GMT
  707. Organization: Syracuse University, Syracuse, NY
  708.  
  709.  
  710. Hi, I would like to be able to open a 'System 7' sound file, and obtain a 
  711. handle to the SoundData of the first 'snd ' resource it contains, but I 
  712. can't figure out how to do this! 
  713. Sadly, none of Apple's Sound Snippets do anything with sound FILES, and 
  714. IM has nothing to offer here either. I looked in IM Files, and IM 
  715. Sound... Nothing!
  716.  
  717. Any help would be great!
  718.  
  719. Adam Smith
  720. smithab@mailbox.syr.edu
  721. Syracuse University
  722. Dept. of Electrical Engineering
  723.  
  724. +++++++++++++++++++++++++++
  725.  
  726. >From James Wilson <WILSON_J@4j.lane.edu>
  727. Date: 4 Mar 1995 23:02:28 GMT
  728. Organization: University of Oregon
  729.  
  730. smithab@forbin.syr.edu (core dumped) wrote:
  731. > Hi, I would like to be able to open a 'System 7' sound file, and obtain a 
  732. > handle to the SoundData of the first 'snd ' resource it contains, but I 
  733. > can't figure out how to do this! 
  734. > Sadly, none of Apple's Sound Snippets do anything with sound FILES, and 
  735. > IM has nothing to offer here either. I looked in IM Files, and IM 
  736. > Sound... Nothing!
  737. > Any help would be great!
  738.  
  739. All that's in a System 7 sound file is a singular 'snd ' resource.
  740. Any more and the Finder will balk at it. Since you won't know the
  741. ID of 'snd ' resource, you must use GetIndResource, like this:
  742.  
  743. Handle soundH;
  744.  
  745. soundH = GetIndResource(soundListRsrc, 1);
  746.  
  747. This will get you the 'snd ' resource within the file.
  748.  
  749. == James Wilson <WILSON_J@4j.lane.edu>
  750.  
  751.  
  752. ---------------------------
  753.  
  754. >From Chris LeCroy <lecroy@ids.net>
  755. Subject: Is it safe to call LaunchApplication from an extension?
  756. Date: 23 Feb 1995 15:48:50 GMT
  757. Organization: SouthBeach Software Corp.
  758.  
  759. While reading Brian Stern's excellent FAQ on system extensions I came
  760. across the statement in answer [2] that goes -  "...things that system
  761. extensions cannot do (or at least cannot do safely), like launch
  762. applications...".
  763.  
  764. Is it unsafe to call LaunchApplication from an extension? Was Brian
  765. just referring to INIT time?  Are there any tricks/caveats in
  766. launching an application from a system extension?
  767.  
  768. Thanks,
  769.  
  770. +++++++++++++++++++++++++++
  771.  
  772. >From jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
  773. Date: 25 Feb 1995 18:20:09 GMT
  774. Organization: Queen Mary & Westfield College
  775.  
  776. In article <3il1ou$4sk@news.halcyon.com>
  777. hawkfish@halcyon.com (Richard Wesley) writes:
  778.  
  779. > In article <3iiap2$gap@paperboy.ids.net>
  780. > Chris LeCroy <lecroy@ids.net> writes:
  781. > > While reading Brian Stern's excellent FAQ on system extensions I came
  782. > > across the statement in answer [2] that goes -  "...things that system
  783. > > extensions cannot do (or at least cannot do safely), like launch
  784. > > applications...".
  785. > > 
  786. > > Is it unsafe to call LaunchApplication from an extension? Was Brian
  787. > > just referring to INIT time?  Are there any tricks/caveats in
  788. > > launching an application from a system extension?
  789. > > 
  790. > > Thanks,
  791. > I don't believe that the process manager is running at INIT time, so _Launch
  792. > would probably have either no effect or rather humourous effects.  If you want
  793. > to launch an app, put an alias in the Startup Items folder.  You could even
  794. > have your INIT do this (and remove it if the app was not to be launched.  There
  795. > is also some mechanism involving applications of type 'appe' but I don't
  796. > knowwhat it involves.
  797. I don't know about launching applications during startup (I've never
  798. tried it), and I suspect that the Startup Items folder would be the
  799. best way to do this. 
  800.  
  801. However, my shareware launcher Apollo is able to use LaunchApplication
  802. without any trouble from within its own INIT code. (Well, hardly any
  803. trouble: there are some minor difficulties when AutoDoubler and a comms
  804. program are running simultaneously, but that's AutoDoubler's fault).
  805.  
  806. 'appe's (background-only applications) are launched in exactly the same
  807. way as true 'APPL's. In fact, provided the file contains all the right
  808. resources, its type seems not to be relevant.
  809.  
  810. Jeremy
  811.  
  812. +++++++++++++++++++++++++++
  813.  
  814. >From Chris LeCroy <lecroy@ids.net>
  815. Date: 2 Mar 1995 16:11:08 GMT
  816. Organization: SouthBeach Software Corp.
  817.  
  818.  Richard Wesley, hawkfish@halcyon.com writes:
  819. > Chris LeCroy <lecroy@ids.net> writes:
  820. > > While reading Brian Stern's excellent FAQ on system extensions I came
  821. > > across the statement in answer [2] that goes -  "...things that system
  822. > > extensions cannot do (or at least cannot do safely), like launch
  823. > > applications...".
  824. > > 
  825. > > Is it unsafe to call LaunchApplication from an extension? Was Brian
  826. > > just referring to INIT time?  Are there any tricks/caveats in
  827. > > launching an application from a system extension?
  828. > > 
  829. > > Thanks,
  830. > I don't believe that the process manager is running at INIT time, so
  831. _Launch
  832. > would probably have either no effect or rather humourous effects.  If
  833. you want
  834. > to launch an app, put an alias in the Startup Items folder.  You could
  835. even
  836. > have your INIT do this (and remove it if the app was not to be
  837. launched.  There
  838. > is also some mechanism involving applications of type 'appe' but I don't
  839. > knowwhat it involves.
  840.  
  841. I probably wasn't clear enough in my original post.  I just want to be
  842. sure that it is safe to call LaunchApplication from an extension that
  843. is being called from a trap patch after everything is up and running. 
  844. I've done the 'appe' thing in the past but have recently been thinking
  845. about  going at things with a system extension.  With the
  846. background-only application approach I was running into some problems
  847. with screen-savers/remote back-up utilities not giving me time for
  848. some reason.  Never figured out why and I don't seem to have the
  849. problem with my when doing the same thing from a system extension (ie.
  850. patch).
  851.  
  852. Rephrasing my original question:  Is there any problem with calling
  853. LaunchApplication from a system extension *after* INIT time?  I've
  854. been doing so and it *seems* to work, but Brian's comment got me
  855. wunderin'.
  856.  
  857. Thanks,
  858.  
  859.  
  860. Chris LeCroy
  861. SouthBeach Software Corp.
  862.  
  863. +++++++++++++++++++++++++++
  864.  
  865. >From BrianS@pbcomputing.com (Brian Stern)
  866. Date: 2 Mar 1995 21:52:05 GMT
  867. Organization: The University of Texas at Austin, Austin, Texas
  868.  
  869. In article <3j4qms$g2h@paperboy.ids.net>, Chris LeCroy <lecroy@ids.net> wrote:
  870.  
  871. <  Richard Wesley, hawkfish@halcyon.com writes:
  872. < > Chris LeCroy <lecroy@ids.net> writes:
  873. < > 
  874. < > > While reading Brian Stern's excellent FAQ on system extensions I came
  875. < > > across the statement in answer [2] that goes -  "...things that system
  876. < > > extensions cannot do (or at least cannot do safely), like launch
  877. < > > applications...".
  878. < > > 
  879. < > > Is it unsafe to call LaunchApplication from an extension? Was Brian
  880. < > > just referring to INIT time?  Are there any tricks/caveats in
  881. < > > launching an application from a system extension?
  882. < > > 
  883. < > > Thanks,
  884. < > 
  885. < > I don't believe that the process manager is running at INIT time, so
  886. < _Launch
  887. < > would probably have either no effect or rather humourous effects.  If
  888. < you want
  889. < > to launch an app, put an alias in the Startup Items folder.  You could
  890. < even
  891. < > have your INIT do this (and remove it if the app was not to be
  892. < launched.  There
  893. < > is also some mechanism involving applications of type 'appe' but I don't
  894. < > knowwhat it involves.
  895. < I probably wasn't clear enough in my original post.  I just want to be
  896. < sure that it is safe to call LaunchApplication from an extension that
  897. < is being called from a trap patch after everything is up and running. 
  898. < I've done the 'appe' thing in the past but have recently been thinking
  899. < about  going at things with a system extension.  With the
  900. < background-only application approach I was running into some problems
  901. < with screen-savers/remote back-up utilities not giving me time for
  902. < some reason.  Never figured out why and I don't seem to have the
  903. < problem with my when doing the same thing from a system extension (ie.
  904. < patch).
  905. < Rephrasing my original question:  Is there any problem with calling
  906. < LaunchApplication from a system extension *after* INIT time?  I've
  907. < been doing so and it *seems* to work, but Brian's comment got me
  908. < wunderin'.
  909. < Thanks,
  910. < Chris LeCroy
  911. < SouthBeach Software Corp.
  912.  
  913. The main reason I said that in the FAQ has to do with appleevents.  If you
  914. want to send an appleevent to the launched app then you need to build it. 
  915. Building an appleevent from an init means that the current process needs
  916. to be high-level-event-aware.  Since you don't have control of that it is
  917. risky to try it.  
  918.  
  919. Having said that, if you're not going to build an apple event to send to
  920. the launched app then you can safely use LaunchApplication.  It is also
  921. conceiveable that you could wait until you were in the Finder's context to
  922. build your apple event, since the Finder is guaranteed to be
  923. high-level-event-aware.
  924.  
  925. FWIW I know that the AppleShare extension launches a process when you
  926. start up the AppleShare File Server app.  But it sends a high level event,
  927. not an apple event.
  928.  
  929. Cheers,
  930.  
  931. -- 
  932. Brian  Stern  :-{)}
  933. Toolbox commando and Menu bard.     Will FlushCache for Cash.
  934. BrianS@pbcomputing.com
  935.  
  936. +++++++++++++++++++++++++++
  937.  
  938. >From jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
  939. Date: 3 Mar 1995 07:32:55 GMT
  940. Organization: Queen Mary & Westfield College
  941.  
  942. In article <BrianS-0203951600400001@slip-10-4.ots.utexas.edu>
  943. BrianS@pbcomputing.com (Brian Stern) writes:
  944.  
  945. > < Rephrasing my original question:  Is there any problem with calling
  946. > < LaunchApplication from a system extension *after* INIT time?  I've
  947. > < been doing so and it *seems* to work, but Brian's comment got me
  948. > < wunderin'.
  949. > The main reason I said that in the FAQ has to do with appleevents.  If you
  950. > want to send an appleevent to the launched app then you need to build it. 
  951. > Building an appleevent from an init means that the current process needs
  952. > to be high-level-event-aware.  Since you don't have control of that it is
  953. > risky to try it.  
  954.  
  955. With the greatest respect, Brian, that's not the case. You need to be
  956. HLE-aware to send an apple event, but anyone can build one. 
  957.  
  958. My INIT builds the open doc apple event, coerces it to whatever the
  959. Launch trap requires (I forget exactly) and then calls _Launch. It
  960. works whether or not the frontmost app is HLE-aware, because the event
  961. seems to be "sent" in a special way by _Launch.
  962.  
  963. Jeremy
  964.  
  965. ---------------------------
  966.  
  967. >From jshanks@maths.otago.ac.nz (John Shanks)
  968. Subject: My own Color Table??
  969. Date: 28 Feb 1995 08:08:31 GMT
  970. Organization: University of Otago
  971.  
  972. Surely there is an easy way to do what I want but many hours reading NIM
  973. hasn't helped:
  974.  
  975. All (??) I want is to open a window with its own color table which I can
  976. then modify to change colors in the window.  256 colors would be fine
  977. (i.e. indexed color) and the window can fill the screen so I don't care
  978. about other applications sharing the colors.  Sounds easy....
  979. I have tried all sorts of things with GWorlds and palettes and copying
  980. color tables and modifying them, but nothing works.  This kind of thing
  981. used to be a breeze with the Apple //gs (remember that?)
  982.  
  983. Can anyone point me in the right direction?
  984.  
  985. Many thanks.
  986.  
  987. -- 
  988. John and Louise Shanks
  989. Dunedin
  990. New Zealand
  991.  
  992. +++++++++++++++++++++++++++
  993.  
  994. >From Bruce@hoult.actrix.gen.nz (Bruce Hoult)
  995. Date: Wed, 1 Mar 1995 16:59:04 +1300 (NZDT)
  996. Organization: (none)
  997.  
  998. jshanks@maths.otago.ac.nz (John Shanks) writes:
  999. > Surely there is an easy way to do what I want but many hours reading NIM
  1000. > hasn't helped:
  1001. > All (??) I want is to open a window with its own color table which I can
  1002. > then modify to change colors in the window.  256 colors would be fine
  1003. > (i.e. indexed color) and the window can fill the screen so I don't care
  1004. > about other applications sharing the colors.  Sounds easy....
  1005. > I have tried all sorts of things with GWorlds and palettes and copying
  1006. > color tables and modifying them, but nothing works.  This kind of thing
  1007. > used to be a breeze with the Apple //gs (remember that?)
  1008.  
  1009. It's worked for me no problems.
  1010.  
  1011. Try using a table with a fewer than 256 colours at first -- the system can
  1012. get a bit snarky if you try to take over all 256, especially if you don't
  1013. put black and white where it expects to find them as first and last
  1014. entries.
  1015.  
  1016. The following worked fine for me, as part of animating a wheel-of-fortune
  1017. game:
  1018.  
  1019.       Var
  1020.          p: PaletteHandle;
  1021.          myWindow: WindowPtr;
  1022.          boundsRect: Rect;
  1023.  
  1024.  
  1025.       SetRect(boundsRect, 0, 20, 640, 480);
  1026.       myWindow := NewCWindow(Nil, boundsRect, 'the title', true, nogrowdocproc, WindowPtr(-1), false, 0);
  1027.       SetPort(myWindow);
  1028.  
  1029.  
  1030.       p := NewPalette(6 + 210, Nil, pmAnimated, 0);
  1031.       SetPalette(FrontWindow, p, true);
  1032.  
  1033.       myColourTab := CTabHandle(Newhandle(0));
  1034.       Palette2CTab(p, myColourTab);
  1035.  
  1036.       DrawSectors;
  1037.       DrawDigits;
  1038.  
  1039.       AnimatePalette(FrontWindow, myColourTab, 0, 0, 6 + 210);
  1040.  
  1041. -- Bruce
  1042.  
  1043. ---------------------------
  1044.  
  1045. >From cerickso@hmc.edu (Chris Erickson)
  1046. Subject: Need help with calling CODE resources
  1047. Date: Fri, 03 Mar 1995 21:56:10 -0800
  1048. Organization: Harvey Mudd College
  1049.  
  1050. I'm writing an application that needs to repetitively call an external
  1051. code resource via the Time Manager. I found code in Think Ref that loads a
  1052. CODE resource into memory and shows you how to call it. It worked fine for
  1053. awhile but  now it has the tendency to crash with "Spurious Interupt in
  1054. _Date2Secs...". This problem disappears if I comment out the code that
  1055. actually calls the routine. BTW, the _Date2Secs call is being generated by
  1056. the system, not my app.
  1057.  
  1058. Here's most the (relevant) code:
  1059.  
  1060. extern Handle        modularDataProc;
  1061. extern DRProcDataPtr theData;
  1062. extern TMInfo        myTMInfo;
  1063.  
  1064. void InstallTMTask (void);
  1065. pascal void MyTask (void);
  1066.  
  1067. pascal void MyTask()
  1068. {
  1069.    long     oldA5;               // A5 when task is called
  1070.    TMInfoPtr   recPtr;
  1071.    
  1072.    recPtr = GetTMInfo();            // first get our TM record
  1073.    oldA5 = ::SetA5(recPtr->tmRefCon);  // Set A5 to app's A5 world
  1074.       
  1075.    short error = 0, counter = theData->numChannelsInUse - 1;
  1076.    
  1077.    ::PrimeTime( (QElemPtr) recPtr, kDelay );
  1078.  
  1079.    ::HLock(modularDataProc);            // Lock the procedure handle
  1080.    error = (* (modularDataProcPtr) (*modularDataProc)) (kGetData, theData,
  1081. 0L);  
  1082.    ::HUnlock(modularDataProc);          // Unlock the procedure handle 
  1083.  
  1084.    // Commenting out above three lines removes problem.
  1085.    .
  1086.    .
  1087.    .
  1088. }
  1089.  
  1090. Are there any other ways to call a CODE resource? I'm pretty sure (though
  1091. not positive) that the code in the call itself is not the culprit.
  1092.  
  1093. Thanks,
  1094.  
  1095. Chris Erickson
  1096. Harvey Mudd College
  1097.  
  1098. +++++++++++++++++++++++++++
  1099.  
  1100. >From oster@netcom.com (David Phillip Oster)
  1101. Date: Sat, 4 Mar 1995 18:02:51 GMT
  1102. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  1103.  
  1104. In article <cerickso-0303952156100001@merlin.st.hmc.edu> cerickso@hmc.edu (Chris Erickson) writes:
  1105. >Here's most the (relevant) code:
  1106.    
  1107. >   ::PrimeTime( (QElemPtr) recPtr, kDelay );
  1108.  
  1109. >   ::HLock(modularDataProc);            // Lock the procedure handle
  1110. >   error = (* (modularDataProcPtr) (*modularDataProc)) (kGetData, theData,
  1111. >0L);  
  1112. >   ::HUnlock(modularDataProc);          // Unlock the procedure handle 
  1113.  
  1114.  
  1115. 1.) Don't lock and unlock the handle from your interrupt routine. This
  1116. is a sure way to corrupt the memory manager. Instead, lock the handle
  1117. in your main-line code.
  1118.  
  1119. 2.) you should be calling StripAddress() before executing the proc
  1120. pointer (more efficient to save the StripAddress'ed proc pointer to a global
  1121. variable.) because you are running at interrupt time, and on machines that
  1122. are normally in 24-bit mode, but switch to 32-bit mode to access video
  1123. cards, starange things can happen if the resource-manager's flag bits
  1124. don't get stripped before the call.
  1125. -- 
  1126. - ------- <mail-to:oster@netcom.com> ----------
  1127. There is no sight finer than that of the planet Earth in your rearview mirror.
  1128.  
  1129.  
  1130.  
  1131. ---------------------------
  1132.  
  1133. >From dave@smartstar.com (Dave Schwartz)
  1134. Subject: Q: TextEdit view-dest rectangles - documented where?
  1135. Date: Thu, 23 Feb 1995 22:51:27 GMT
  1136. Organization: SmartStar Corp.
  1137.  
  1138.  
  1139. In "Inside Macintosh:Text" ch 2 (TextEdit) there is a rather cursory
  1140. description of how the TextEdit uses view and destination rectangles.  The
  1141. reader is referred to "... the QuickDraw chapters in Inside Macintosh:
  1142. Imaging" for more information.
  1143. Although I cannot find a volume called "Imaging" in the NIM set, I have
  1144. found one called "Imaging with QuickDraw" which seems to have the content
  1145. that is described for the "Imaging" volume in the NIM chart on the last
  1146. page (backispiece??) of the "Text" volume.  However, I have searched
  1147. through "Imaging with QuickDraw" for several hours, and the only thing I
  1148. came up with is a brief discussion of scaling a picture to fit in a
  1149. destination rectangle when using DrawPicture (p 7-18). I have also
  1150. searched the CDROM version on the (Reference Library) Developer CD.
  1151.  
  1152. I am somewhat of a newbie at graphical interface programming, and I have
  1153. inherited some code that seems to misuse the TextEdit by creating a
  1154. destination rectangle much larger than the view rectangle even though the
  1155. text that is being displayed is _not_ supposed to scroll (this is a short,
  1156. single line text entry field with a constrained length). 
  1157.  
  1158. Before I change it, I'd like to have a better idea of what I'm doing.  Can
  1159. someone point me to a more detailed explanation of how the view and
  1160. destination rectangles are intended to be used?   I think that I can call
  1161. TEAutoView and use TESelView whenever TEActivate is called, but I'd rather
  1162. try to understand the use of the rectangles.
  1163. Thanks.
  1164.  
  1165. -- 
  1166. Dave Schwartz       | "It's the blind leading the blind, and I am amazed
  1167. dave@smartstar.com  |  How they stumble homeward through the haze"
  1168. VMS FOREVER         |                                    David Crosby
  1169.  
  1170. +++++++++++++++++++++++++++
  1171.  
  1172. >From brawer@coli.uni-sb.de (Sascha Brawer)
  1173. Date: Tue, 28 Feb 1995 17:42:02 +0100
  1174. Organization: Dept. of Comp. Linguistics, Uni des Saarlandes, DE
  1175.  
  1176. In article <dave-2302951447490001@crosby.smartstar.com>,
  1177. dave@smartstar.com (Dave Schwartz) wrote:
  1178.  
  1179. > [...] Can someone point me to a more detailed explanation of how the view and
  1180. > destination rectangles are intended to be used?
  1181.  
  1182. Use the view rectangle for the area where text shall be visible (i.e. the box
  1183. to enter the text); use the destination rectangle for the "logical" size of
  1184. the text. The wrapping of the text is performed according to the destRect
  1185. (ignoring its bottom edge), but the drawing will be clipped to the
  1186. viewRect.
  1187.  
  1188. See the *old* Inside Macintosh, Vol. I, p. I-374, or consider the picture
  1189. in the New Inside Mac.: Text, p. 2-16.
  1190. At the latter location, consider the right of the two images: Only the
  1191. grey-shaded part will be visible on the screen, and to see the non-shaded
  1192. part of the text, the user will have to scroll with the mouse or by using
  1193. the cursor keys.
  1194.  
  1195. -- Sascha Brawer
  1196.  
  1197. - -------------------------------------------------------------------
  1198. Sascha Brawer   (Student of Computational Linguistics)
  1199.  
  1200. e-Mail:         brawer@coli.uni-sb.de
  1201. URL:            http://coli.uni-sb.de/~brawer/
  1202. Address:        Stengelstrasse 18, D-66117 Saarbruecken
  1203. Phone:          (+49 681) 589 85 66
  1204. - -------------------------------------------------------------------
  1205.  
  1206. ---------------------------
  1207.  
  1208. >From bb@lightside.com (Bob Bradley)
  1209. Subject: Q: What are Exceptions?
  1210. Date: 27 Feb 1995 10:29:19 GMT
  1211. Organization: SPC
  1212.  
  1213. What are exceptions? I've seen a lot of people talking about them but, I'm
  1214. not sure what they are or how they are better than what people are using
  1215. without them. I assume they are some form of error detection or how errors
  1216. are handled. How are they better than the regular "if an error occured,
  1217. display error" type error handling?
  1218.  
  1219. +++++++++++++++++++++++++++
  1220.  
  1221. >From "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu>
  1222. Date: Mon, 27 Feb 1995 14:49:20 -0500
  1223. Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA
  1224.  
  1225. Excerpts from netnews.comp.sys.mac.programmer.misc: 27-Feb-95 Q: What
  1226. are Exceptions? Bob Bradley@lightside.co (331*)
  1227.  
  1228. > What are exceptions? I've seen a lot of people talking about them but, I'm
  1229. > not sure what they are or how they are better than what people are using
  1230. > without them. I assume they are some form of error detection or how errors
  1231. > are handled.
  1232.  
  1233. The idea is that you can execute a statement with an error handler.
  1234. Typical syntax (from C++) is:
  1235.  
  1236. try { STATEMENT } 
  1237.    catch (ERROR TYPE) { HANDLER-STATEMENT };
  1238.  
  1239. Then, if the statement encounters an error, it can throw an exception of
  1240. the appropriate type. This causes the statement to immediately stop
  1241. executing, and control goes straight to the handler.
  1242.  
  1243. This may sound like a baroque way to write "if (!error) {...}", and on
  1244. the simplest level it is. The strength of the technique is that
  1245. exceptions can be thrown from inside nested functions called by
  1246. STATEMENT; each function aborts and exits until control reaches the
  1247. handler. If there is no handler, the entire program exits with a
  1248. run-time error. (There are more details, of course; you can typically
  1249. have multiple handlers and handlers that throw more exceptions and
  1250. whatever.)
  1251.  
  1252. Like any tool, you can use this well or stupidly. I find myself writing
  1253. a lot of code which has several interacting procedures, each of which
  1254. does some stuff and returns an error code or noErr, and every step is
  1255. followed by "if (error) return error;". If I used exceptions, I could
  1256. get the same effect without wasting verbiage on that sort of thing. It
  1257. also keeps you from wasting the function's return value on
  1258. error-checking. 
  1259.  
  1260. Sadly, I'm using C, and there ain't no exceptions to use. Sigh.
  1261.  
  1262. Another example: you open a file, and then call some complicated
  1263. file-diddling code. The file-diddling can encounter all sorts of errors
  1264. caused by bad file format. Rather than writing code to unwind the data
  1265. you've loaded and close the file after each error, you put on an
  1266. exception handler that does all that.
  1267.  
  1268. Some people hate handlers because they remind them of "goto". I like
  1269. handlers because they remind me of "break" and "return", only more
  1270. flexible.
  1271.  
  1272. --Z
  1273.  
  1274. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  1275.  
  1276. +++++++++++++++++++++++++++
  1277.  
  1278. >From jens_alfke@powertalk.apple.com (Jens Alfke)
  1279. Date: Tue, 28 Feb 1995 21:27:05 GMT
  1280. Organization: Apple Computer, Inc.
  1281.  
  1282. In article <ojIWn0_00gpI1oAmck@andrew.cmu.edu>, "Andrew C. Plotkin"
  1283. <ap1i+@andrew.cmu.edu> wrote:
  1284.  
  1285. > Sadly, I'm using C, and there ain't no exceptions to use. Sigh.
  1286.  
  1287. Not true; you can fake exception handling using setjmp and longjmp just
  1288. like C++ programmers do. One thing I did a long time ago was take code
  1289. from the TCL that does exception handling; it doesn't use any non-C
  1290. features. (This may have changed with the newer versions of the TCL.)
  1291. Basically it takes about 1k of code to do a pretty good simulation of
  1292. exception handling.
  1293.  
  1294.  
  1295. Jens Alfke_________OpenDoc Geometer_________jens_alfke@powertalk.apple.com
  1296.                                            OpenDoc info: FTP to CILabs.org
  1297.  
  1298.          Visit Scenic Flood Control Dam No. 3.      
  1299.  
  1300. ---------------------------
  1301.  
  1302. >From Nick Clarke:  <74730.1570@CompuServe.COM>
  1303. Subject: Screen saver info needed
  1304. Date: 28 Feb 1995 10:18:57 GMT
  1305. Organization: The BootRoom
  1306.  
  1307. Screen saver info needed
  1308.  
  1309. I am trying to write a control panel that is a screen saver.  I am a
  1310. bit stuck about what to do.  I have a few questions.
  1311. 1) How do you save data, ie the number of minutes before saver 
  1312. activates?
  1313. 2) I presume I have to insert a VBL task.  Do I call it once with 
  1314. the time setting to be the number of ticks before activation, or 
  1315. regularly?
  1316. 3) How after the activation time, do I handle the call back when it 
  1317. is from a control panel?
  1318. 4) When I patch GetNextEvent etc I assume that I clear the VBL task 
  1319. and reset it between each event
  1320. 5) Are there any other pitfalls I should look out for?
  1321.  
  1322. Thanks
  1323.  
  1324. Nick Clarke
  1325.  
  1326. -- 
  1327. Nick Clarke: The BootRoom: 74730.1570@compuserve.com. 
  1328.  
  1329. +++++++++++++++++++++++++++
  1330.  
  1331. >From Matt Slot <fprefect@umich.edu>
  1332. Date: 28 Feb 1995 14:47:04 GMT
  1333. Organization: University of Michigan
  1334.  
  1335. Nick Clarke:, 74730.1570@CompuServe.COM writes:
  1336.  > 1) How do you save data, ie the number of minutes before saver 
  1337.  > activates?
  1338.  
  1339. Storing globals is highly dependent on your development environment.
  1340. THINK C
  1341. uses a strangely different system for keeping global data in a Code
  1342. resource,
  1343. etc. I would suggest that you look for sample source and for the dox about
  1344. the particulars, or repost with that info (actually it may be in the FAQ).
  1345.  
  1346.  
  1347.  > 2) I presume I have to insert a VBL task.  Do I call it once with 
  1348.  > the time setting to be the number of ticks before activation, or 
  1349.  > regularly?
  1350.  
  1351. Typically there is no need to have a VBL task. You can get time to 
  1352. work by patching something mundane like SystemTask() -- VBL's are a
  1353. bit of overkill.
  1354.  
  1355.  
  1356.  > 3) How after the activation time, do I handle the call back when it 
  1357.  > is from a control panel?
  1358.  
  1359. Your Code resource should leave itself locked, then call RecoverHandle()
  1360. and
  1361. DetachResource()  at your startup -- then your code is left in memory. 
  1362. When you patch a routine (at least globally), the patch should simply be 
  1363. with a second function from your Code resource.
  1364.  
  1365.  
  1366.  > 4) When I patch GetNextEvent etc I assume that I clear the VBL task 
  1367.  > and reset it between each event
  1368.  
  1369. I would discourage you from patching GetNextEvent(), but rather look at
  1370. the jGNEFilter samples and tracking the mouse position.
  1371.  
  1372.  
  1373.  > 5) Are there any other pitfalls I should look out for?
  1374.  
  1375. Start with the thoughts above... look at the FAQ and some sample source.
  1376. There are several pitfalls, and you will have more info on resolving the
  1377. problems.
  1378.  
  1379. +++++++++++++++++++++++++++
  1380.  
  1381. >From Nick Clarke:  <74730.1570@CompuServe.COM>
  1382. Date: 28 Feb 1995 19:03:15 GMT
  1383. Organization: The BootRoom
  1384.  
  1385. Matt
  1386. Thanks for the advice - I'll try your suggestions: Couple more 
  1387. things: Where can I get the FAQ and do you know where I can get some
  1388. sample source code for Control Panel (ideally a screen saver). This 
  1389. may help me plan better
  1390. Nick
  1391.  
  1392. -- 
  1393. Nick Clarke: The BootRoom: 74730.1570@compuserve.com. 
  1394.  
  1395. +++++++++++++++++++++++++++
  1396.  
  1397. >From h+@metrowerks.com (Jon W{tte)
  1398. Date: Sat, 04 Mar 1995 12:10:33 +0100
  1399. Organization: The Conspiracy
  1400.  
  1401.  
  1402. In article <3iutah$6cc$1@mhade.production.compuserve.com>,
  1403. Nick Clarke:  <74730.1570@CompuServe.COM> wrote:
  1404.  
  1405. > 1) How do you save data, ie the number of minutes before saver 
  1406. > activates?
  1407.  
  1408. In a preferences file in the preferences folder (use FindFolder 
  1409. to find the Preferences folder)
  1410.  
  1411. > 2) I presume I have to insert a VBL task.  Do I call it once with 
  1412. > the time setting to be the number of ticks before activation, or 
  1413. > regularly?
  1414.  
  1415. Uh, no, you don't need a VBL task. If you install one, the 
  1416. system will call it for you regularly, [a multiple of] each 
  1417. time the screen goes through a vertical blanking period (i e 
  1418. when the electron beam goes from bottom to top to repaint the 
  1419. screen) This happens 50-80 times a second.
  1420.  
  1421. > 3) How after the activation time, do I handle the call back when it 
  1422. > is from a control panel?
  1423.  
  1424. Your control panel must have an INIT part that installs code in 
  1425. the system heap.
  1426.  
  1427. > 4) When I patch GetNextEvent etc I assume that I clear the VBL task 
  1428. > and reset it between each event
  1429.  
  1430. Don't patch GetNextEvent. If you want to get into that 
  1431. functionality, you should use the jGNEFilter. There is 
  1432. something called the jGNEFilter helper on the archives with 
  1433. sample code.
  1434.  
  1435. > 5) Are there any other pitfalls I should look out for?
  1436.  
  1437. Yes; don't write an INIT/Control Panel combo. Patching traps 
  1438. with 68K code hurts performance on PowerPC systems really bad. 
  1439. There are tens of freeware screen savers out there, along with 
  1440. several shareware and commercialware ones. Why write your own? 
  1441. When in "blanking" mode, how do you expect to keep up 
  1442. background processing? How do you expect to stop other 
  1443. applications from drawing to the screen?
  1444.  
  1445. The correct thing to do, which doesn't patch anything at all, 
  1446. is to write an APPLICATION which, on WaitNextEvent idle time, 
  1447. checks for keys down or button down, and resets its internal 
  1448. counter. Once it's time to fade, it opens a window and sets 
  1449. itself to front with SetFrontProcess(). This is <simplified> 
  1450. what Dark Side of the Mac does; the premier non-commercial Mac 
  1451. screen saver. Check it out. Do something useful with your time.
  1452.  
  1453. Cheers,
  1454.  
  1455.                                                 / h+
  1456.  
  1457.  
  1458. --
  1459.   Jon Wdtte (h+@metrowerks.com), Hagagatan 1, 113 48 Stockholm, Sweden
  1460.  
  1461.  "These really aren't my opinions. I just fed them and they followed me home."
  1462.  
  1463.  
  1464. ---------------------------
  1465.  
  1466. >From quag@netcom.com (Matt Quagliana)
  1467. Subject: Transparent QuickTime?
  1468. Date: Thu, 16 Feb 1995 16:54:08 GMT
  1469. Organization: Cerebus Corporation
  1470.  
  1471. I am trying to do something with QuickTime that might not be possible, 
  1472. but I can't find any information to either confirm or deny my suspicion.
  1473.  
  1474. I am writing an application using Novell AppWare, a high level visual 
  1475. programming tool. The exact choice of tools shouldn't matter, but I 
  1476. mention it because I am not working at the C/C++ level.
  1477.  
  1478. In AppWare I have the ability to display PICT images in windows, and to
  1479. play QuickTime movies in windows. What I want to do is play a QuickTime
  1480. movie *in front of* a picture, so that the movie is superimposed on the
  1481. static image. 
  1482.  
  1483. Currently, this doesn't work because the QuickTime rectangle masks out 
  1484. everything below it, i.e. my movie plays inside a box of white space, 
  1485. hiding the picture behind it.
  1486.  
  1487. Does QuickTime support the ability to create and play movies with 
  1488. transparent backgrounds, or am I SOL?
  1489.  
  1490. Thanks in advance...
  1491.  
  1492. Matt Quagliana
  1493. Cerebus Corporation
  1494. quag@cerebus.com
  1495. (214) 855-0880
  1496.  
  1497. +++++++++++++++++++++++++++
  1498.  
  1499. >From Scott Hutinger <S-Hutinger@bgu.edu>
  1500. Date: 16 Feb 1995 21:25:07 GMT
  1501. Organization: Macomb Projects
  1502.  
  1503. In article <quagD43qy8.C77@netcom.com> Matt Quagliana, quag@netcom.com
  1504. writes:
  1505. >In AppWare I have the ability to display PICT images in windows, and to
  1506. >play QuickTime movies in windows. What I want to do is play a QuickTime
  1507. >movie *in front of* a picture, so that the movie is superimposed on the
  1508. >static image. 
  1509. >
  1510. >Currently, this doesn't work because the QuickTime rectangle masks out 
  1511. >everything below it, i.e. my movie plays inside a box of white space, 
  1512. >hiding the picture behind it.
  1513. >
  1514. >Does QuickTime support the ability to create and play movies with 
  1515. >transparent backgrounds, or am I SOL?
  1516.  
  1517. What I do is 
  1518. 1) make the background picture
  1519. 2) copy the size and location of where the  movie is going to play on top
  1520. of the picture.
  1521. 3) put that picture as the background in the movie (using a Quicktime
  1522. editor)
  1523. 4) chromakey someone into the movie
  1524. 5) play the movie back onto the same location I stole the picture from.
  1525.  
  1526. Then you have the Heavy Metal girls in your application!  But, to answer
  1527. your question, I don't think your application will support any masks or
  1528. other things you can do with quicktime, other than play a movie.  
  1529.  
  1530. Is the picture behind the movie the same size as the movie itself?  If
  1531. so, your SOL, unless you make your movie the way I do.
  1532.  
  1533. scott
  1534. s-hutinger@bgu.edu
  1535.  
  1536. +++++++++++++++++++++++++++
  1537.  
  1538. >From ldo@waikato.ac.nz (Lawrence D9Oliveiro)
  1539. Date: Fri, 17 Feb 1995 17:14:49 +1300
  1540. Organization: University of Waikato
  1541.  
  1542. In article <quagD43qy8.C77@netcom.com>, quag@netcom.com (Matt Quagliana) wrote:
  1543.  
  1544. >What I want to do is play a QuickTime
  1545. >movie *in front of* a picture, so that the movie is superimposed on the
  1546. >static image. 
  1547. >
  1548. >Currently, this doesn't work because the QuickTime rectangle masks out 
  1549. >everything below it, i.e. my movie plays inside a box of white space, 
  1550. >hiding the picture behind it.
  1551. >
  1552. >Does QuickTime support the ability to create and play movies with 
  1553. >transparent backgrounds, or am I SOL?
  1554.  
  1555. Yes, you certainly can do this. Look for the SetVideoMediaGraphicsMode
  1556. call: this lets you specify any QuickDraw drawing mode for a video track,
  1557. including transparent mode.
  1558.  
  1559. However, it's not enough to make a single track transparent: you'll just
  1560. get bits of garbage wherever the transparent colour appears in a frame. In
  1561. order to get the static image to draw in the transparent parts, you have
  1562. to make that image a video track in the movie in its own right, positioned
  1563. behind the moving track. This background track only needs to contain a
  1564. single frame with a very long duration, so the size it would add to your
  1565. movie is minimal.
  1566.  
  1567. Note that using such fancy drawing modes would probably add a performance
  1568. penalty to your movie.
  1569.  
  1570. +++++++++++++++++++++++++++
  1571.  
  1572. >From soori@netcom.com (Mahesh Sooriarachchi)
  1573. Date: Tue, 21 Feb 1995 00:47:33 GMT
  1574. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  1575.  
  1576. You can give a mask (RgnHandle) to q quicktime moview that will be used
  1577. to clip the movie.  What I would do is to create a B/W PICTure that is
  1578. the mask you want, creae a 1 bit gWorld, draw the b/w picture into it, 
  1579. call PixMapToRegion() to create the mask you want, then set the movie's mask
  1580. by calling SetTrackClipRgn() for the track.
  1581.  
  1582. Good Luck.
  1583.  
  1584.  
  1585. In article 
  1586. <quagD43qy8.C77@netcom.com> quag@netcom.com (Matt Quagliana) writes:
  1587. >I am trying to do something with QuickTime that might not be possible, 
  1588. >but I can't find any information to either confirm or deny my suspicion.
  1589. >
  1590. >I am writing an application using Novell AppWare, a high level visual 
  1591. >programming tool. The exact choice of tools shouldn't matter, but I 
  1592. >mention it because I am not working at the C/C++ level.
  1593. >
  1594. >In AppWare I have the ability to display PICT images in windows, and to
  1595. >play QuickTime movies in windows. What I want to do is play a QuickTime
  1596. >movie *in front of* a picture, so that the movie is superimposed on the
  1597. >static image. 
  1598. >
  1599. >Currently, this doesn't work because the QuickTime rectangle masks out 
  1600. >everything below it, i.e. my movie plays inside a box of white space, 
  1601. >hiding the picture behind it.
  1602. >
  1603. >Does QuickTime support the ability to create and play movies with 
  1604. >transparent backgrounds, or am I SOL?
  1605. >
  1606. >Thanks in advance...
  1607. >
  1608. >Matt Quagliana
  1609. >Cerebus Corporation
  1610. >quag@cerebus.com
  1611. >(214) 855-0880
  1612.  
  1613.  
  1614. -- 
  1615. Lets DIVIDE and conquer the Pentium!
  1616.  
  1617. PowerPC to the rescue!
  1618.  
  1619. Mahesh Soori. - My openions are mine, not of my employer!
  1620.  
  1621. +++++++++++++++++++++++++++
  1622.  
  1623. >From f94mad@efd.lth.se (Markus Andreasson)
  1624. Date: 23 Feb 1995 09:14:31 GMT
  1625. Organization: Lund Institute of Technology, Sweden
  1626.  
  1627. In article <quagD43qy8.C77@netcom.com>, quag@netcom.com (Matt Quagliana) writes:
  1628. > I am trying to do something with QuickTime that might not be possible, 
  1629. > but I can't find any information to either confirm or deny my suspicion.
  1630. > I am writing an application using Novell AppWare, a high level visual 
  1631. > programming tool. The exact choice of tools shouldn't matter, but I 
  1632. > mention it because I am not working at the C/C++ level.
  1633. > In AppWare I have the ability to display PICT images in windows, and to
  1634. > play QuickTime movies in windows. What I want to do is play a QuickTime
  1635. > movie *in front of* a picture, so that the movie is superimposed on the
  1636. > static image. 
  1637. > Currently, this doesn't work because the QuickTime rectangle masks out 
  1638. > everything below it, i.e. my movie plays inside a box of white space, 
  1639. > hiding the picture behind it.
  1640. > Does QuickTime support the ability to create and play movies with 
  1641. > transparent backgrounds, or am I SOL?
  1642. > Thanks in advance...
  1643.  
  1644. I'm playing QuickTime movies in front of pictures in Director. I just
  1645. give the movie a transparent background and it works fine (if the movie's
  1646. original background is white). Perhaps there's a similar option in Novell
  1647. AppWare?
  1648.  
  1649. _._._
  1650. Markus Andreasson  f94mad@efd.lth.se
  1651.  
  1652.  
  1653. +++++++++++++++++++++++++++
  1654.  
  1655. >From fixer@faxcsl.dcrt.nih.gov (Chris Tate)
  1656. Date: Thu, 23 Feb 1995 13:52:46 GMT
  1657. Organization: DCRT, NIH, Bethesda, MD
  1658.  
  1659. In article <quagD43qy8.C77@netcom.com>, quag@netcom.com (Matt Quagliana) writes:
  1660. >
  1661. >I am trying to do something with QuickTime that might not be possible, 
  1662. >but I can't find any information to either confirm or deny my suspicion.
  1663. >
  1664. > [....]
  1665. >
  1666. >In AppWare I have the ability to display PICT images in windows, and to
  1667. >play QuickTime movies in windows. What I want to do is play a QuickTime
  1668. >movie *in front of* a picture, so that the movie is superimposed on the
  1669. >static image. 
  1670. >
  1671. >Currently, this doesn't work because the QuickTime rectangle masks out 
  1672. >everything below it, i.e. my movie plays inside a box of white space, 
  1673. >hiding the picture behind it.
  1674.  
  1675. It's possible, but it's tricky.  Actually, it's pretty slick, but it's still
  1676. quite a bit more trouble than simply playing a QuickTime movie directly into
  1677. a window.
  1678.  
  1679. You need to dig down into animation techniques yourself for this.  The most
  1680. straightforward technique requires that you have three (possibly only two)
  1681. offscreen buffers (use GWorlds):
  1682.  
  1683.         1) The window contents, without any movie data cluttering it up
  1684.         2) A GWorld to play the movie into
  1685.         3) A scratch buffer
  1686.  
  1687. For every frame of the movie (!), you copy buffer 1) into buffer 3).  This
  1688. gives you, at every frame, a 'plain' background image.  Then, you draw one
  1689. frame of the QuickTime movie into buffer 2).  Next, you use CopyBits() with
  1690. an appropriate transfer mode or mask to blit *just the 'opaque' parts of
  1691. the movie frame* on top of the background image in buffer 3).  At this point,
  1692. buffer 3) consists of the 'background' image, overlaid with the current frame
  1693. of the QT movie.
  1694.  
  1695. Finally, you blit buffer 3) onto the screen.
  1696.  
  1697. Yeah, this sounds slow.  The problem is that QuickTime can't support this
  1698. sort of thing directly; it has no way of knowing what image data it has
  1699. overwritten in your window, and so you have to have some way of restoring
  1700. the 'background' image for every frame of the movie.
  1701.  
  1702. If someone has a better approach than this, I'd love to hear about it... :-)
  1703.  
  1704. For what it's worth, there's a guy at Apple who used similar techniques on
  1705. a PowerMac to get respectable animation speed doing realtime image mapping
  1706. of a running QuickTime movie onto a rotating, moving 3D surface (a cube, or
  1707. a cylinder, or a Bezier surface, or....).  So, this sort of thing *can* work
  1708. fast enough to be usable, at least on a PowerMac.
  1709.  
  1710. - ----------------------------------------------------------
  1711. Christopher Tate           | "I love it when you use me as
  1712. fixer@faxcsl.dcrt.nih.gov  |  a split-screen montage!"
  1713. eWorld:  cTate             |   -- "Whose Line Is It Anyway?"
  1714.  
  1715. +++++++++++++++++++++++++++
  1716.  
  1717. >From rudolph@unixg.ubc.ca (Chris Rudolph)
  1718. Date: Thu, 23 Feb 1995 08:30:38 -0800
  1719. Organization: Motion Works International
  1720.  
  1721. In article <1995Feb23.135246.17516@alw.nih.gov>, fixer@faxcsl.dcrt.nih.gov
  1722. wrote:
  1723.  
  1724. > It's possible, but it's tricky.  Actually, it's pretty slick, but it's still
  1725. > quite a bit more trouble than simply playing a QuickTime movie directly into
  1726. > a window.
  1727. > You need to dig down into animation techniques yourself for this.  The most
  1728. > straightforward technique requires that you have three (possibly only two)
  1729. > offscreen buffers (use GWorlds):
  1730. >         1) The window contents, without any movie data cluttering it up
  1731. >         2) A GWorld to play the movie into
  1732. >         3) A scratch buffer
  1733.  
  1734. Dohhhhhhhh!
  1735.  
  1736. That would use up alot of memory needlessly.  Here is a better way of
  1737. doing what you want, assuming you know where on top of the Picture you
  1738. intend to play the movie.
  1739.  
  1740. Create an offscreen gworld ( use temporary memory, since we only need it
  1741. for a short time ) that is the same size as the movie.
  1742.  
  1743. Image the Picture into the offscreen, without scaling.
  1744. Get the first video track in the movie, create a new video track, and copy
  1745. the settings of the first track to the new track.  
  1746. Enable the new track.
  1747. Create a new media sample using the gworld sample data as the data
  1748. reference, and dhlr type as 'hndl'.
  1749. BeginMediaEdits - AddMediaSample - EndMediaEdits.
  1750. Insert the media into the new track, scale the track segment to be the
  1751. same size as the duration of the movie.
  1752. Set the layering of the new track ( SetTrackLayer ) to a value greater
  1753. than the first video track.
  1754.  
  1755. Get the mediahandler for the first video track and call
  1756. MediaSetGraphicsMode with a transparent setting and white as the operand
  1757. color.
  1758. Get the mediahandler for the new video track and call MediaSetGraphicsMode
  1759. with a srcCopy setting and black as the operand color.
  1760.  
  1761. Play the movie.
  1762.  
  1763. Thats all there is to it.  I'll happily answer any questions regarding this.
  1764.  
  1765. - -------------------------------------------------------------------
  1766. Chris Rudolph, Senior Engineer,
  1767. Technology Works.
  1768. Motion Works International.
  1769.  
  1770. Internet:  rudolph@unixg.ubc.ca
  1771. AppleLink: D2276 ( Subject: Attn: Chris Rudolph )
  1772. - -------------------------------------------------------------------
  1773.  
  1774. +++++++++++++++++++++++++++
  1775.  
  1776. >From ivanski@world.std.com (Ivan M CaveroBelaunde)
  1777. Date: Thu, 2 Mar 1995 04:42:10 GMT
  1778. Organization: The World Public Access UNIX, Brookline, MA
  1779.  
  1780. rudolph@unixg.ubc.ca (Chris Rudolph) writes:
  1781.  
  1782. >In article <1995Feb23.135246.17516@alw.nih.gov>, fixer@faxcsl.dcrt.nih.gov
  1783. >wrote:
  1784. >That would use up alot of memory needlessly.  Here is a better way of
  1785. >doing what you want, assuming you know where on top of the Picture you
  1786. >intend to play the movie.
  1787.  
  1788. >Create an offscreen gworld ( use temporary memory, since we only need it
  1789. >for a short time ) that is the same size as the movie.
  1790.  
  1791. >Image the Picture into the offscreen, without scaling.
  1792. >Get the first video track in the movie, create a new video track, and copy
  1793. >the settings of the first track to the new track.  
  1794. >Enable the new track.
  1795. >Create a new media sample using the gworld sample data as the data
  1796. >reference, and dhlr type as 'hndl'.
  1797. >BeginMediaEdits - AddMediaSample - EndMediaEdits.
  1798. >Insert the media into the new track, scale the track segment to be the
  1799. >same size as the duration of the movie.
  1800. >Set the layering of the new track ( SetTrackLayer ) to a value greater
  1801. >than the first video track.
  1802.  
  1803. >Get the mediahandler for the first video track and call
  1804. >MediaSetGraphicsMode with a transparent setting and white as the operand
  1805. >color.
  1806. >Get the mediahandler for the new video track and call MediaSetGraphicsMode
  1807. >with a srcCopy setting and black as the operand color.
  1808.  
  1809. >Play the movie.
  1810.  
  1811.  
  1812. Actually, it 's not even necessary to create a track with the background
  1813. image. HJust set the media graphics mode for the frontmost video
  1814. track, and use the SetMovieCoverProcs call to draw the movie's
  1815. background.
  1816.  
  1817. -Ivan
  1818. - -
  1819. Ivan Cavero Belaunde (ivanski@world.std.com, ivan_cavero-belaunde@avid.com)
  1820. Avid Technology, Inc.
  1821.  
  1822. ---------------------------
  1823.  
  1824. End of C.S.M.P. Digest
  1825. **********************
  1826.